package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.FndBaseRate;
import com.bestow.basic.service.IFndBaseRateService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 基准利率Controller
 * 
 * @author liliu
 * @date 2022-09-02
 */
@RestController
@RequestMapping("/system/baseRate")
public class FndBaseRateController extends BaseController
{
    @Autowired
    private IFndBaseRateService fndBaseRateService;

    /**
     * 查询基准利率列表
     */
    @PreAuthorize("@ss.hasPermi('system:baseRate:list')")
    @GetMapping("/list")
    public TableDataInfo list(FndBaseRate fndBaseRate)
    {
        startPage();
        List<FndBaseRate> list = fndBaseRateService.selectFndBaseRateList(fndBaseRate);
        return getDataTable(list);
    }

    /**
     * 导出基准利率列表
     */
    @PreAuthorize("@ss.hasPermi('system:baseRate:export')")
    @Log(title = "基准利率", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FndBaseRate fndBaseRate)
    {
        List<FndBaseRate> list = fndBaseRateService.selectFndBaseRateList(fndBaseRate);
        ExcelUtil<FndBaseRate> util = new ExcelUtil<FndBaseRate>(FndBaseRate.class);
        util.exportExcel(response, list, "基准利率数据");
    }

    /**
     * 获取基准利率详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:baseRate:query')")
    @GetMapping(value = "/{baseRateId}")
    public AjaxResult getInfo(@PathVariable("baseRateId") Long baseRateId)
    {
        return AjaxResult.success(fndBaseRateService.selectFndBaseRateByBaseRateId(baseRateId));
    }

    /**
     * 新增基准利率
     */
    @PreAuthorize("@ss.hasPermi('system:baseRate:add')")
    @Log(title = "基准利率", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FndBaseRate fndBaseRate)
    {
        return toAjax(fndBaseRateService.insertFndBaseRate(fndBaseRate));
    }

    /**
     * 修改基准利率
     */
    @PreAuthorize("@ss.hasPermi('system:baseRate:edit')")
    @Log(title = "基准利率", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FndBaseRate fndBaseRate)
    {
        return toAjax(fndBaseRateService.updateFndBaseRate(fndBaseRate));
    }

    /**
     * 删除基准利率
     */
    @PreAuthorize("@ss.hasPermi('system:baseRate:remove')")
    @Log(title = "基准利率", businessType = BusinessType.DELETE)
	@DeleteMapping("/{baseRateIds}")
    public AjaxResult remove(@PathVariable Long[] baseRateIds)
    {
        return toAjax(fndBaseRateService.deleteFndBaseRateByBaseRateIds(baseRateIds));
    }
}
